<template>
  <el-card shadow="have">
    <div slot="header">
      <span>教材使用详情</span>
    </div>
    <div>
      <el-form inline :form="form">
        <el-form-item label="教材名称/ISBN">
          <el-input v-model="form.search_key" type="text" placeholder="请输入教材名称/ISBN" />
        </el-form-item>
        <el-form-item label="省份">
          <el-select v-model="form.search_area">
            <el-option v-for="item in areaList(1)" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="学校级别">
          <el-select v-model="form.search_school_type">
            <el-option :label="'高职'" :value="1" />
          </el-select>
        </el-form-item>
        <el-form-item label="查询时间">
          <el-date-picker
            v-model="form.search_time"
            type="monthrange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="form.pickerOptions"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary">查询</el-button>
        </el-form-item>
      </el-form>

      <el-divider />

      <el-table border :data="tableData">
        <el-table-column prop="book_name" label="教材名称" />
        <el-table-column prop="ISBN" label="ISBN" />
        <el-table-column prop="area_sum" label="省份数" />
        <el-table-column prop="choose_school_sum" label="选用学校数" sortable />
        <el-table-column prop="choose_course_sum" label="使用课程数" sortable />
        <el-table-column prop="choose_sum" label="总选用量" sortable />
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button type="text">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="1"
        :page-sizes="[100, 200, 300, 400]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="400"
      />
    </div>
  </el-card>
</template>
<script>

export default {
  name: 'BookHaveTable',
  props: {
    areaList: {
      type: Function,
      default() {
        return function() {}
      }
    }
  },
  data() {
    return {
      form: {
        search_key: '',
        search_area: '',
        search_school_type: '',
        search_time: '',
        pickerOptions: {
          shortcuts: [{
            text: '本月',
            onClick(picker) {
              picker.$emit('pick', [new Date(), new Date()])
            }
          }, {
            text: '今年至今',
            onClick(picker) {
              const end = new Date()
              const start = new Date(new Date().getFullYear(), 0)
              picker.$emit('pick', [start, end])
            }
          }, {
            text: '最近六个月',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setMonth(start.getMonth() - 6)
              picker.$emit('pick', [start, end])
            }
          }]
        }
      },
      tableData: [
        { book_name: '高等数学', ISBN: '9787111455028', area_sum: 16, choose_school_sum: 15, choose_course_sum: 45, choose_sum: 35 },
        { book_name: '土壤农化分析', ISBN: '9787111521891', area_sum: 15, choose_school_sum: 16, choose_course_sum: 34, choose_sum: 14 },
        { book_name: '土地经济学', ISBN: '9787111385189', area_sum: 13, choose_school_sum: 12, choose_course_sum: 54, choose_sum: 34 }
      ]
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
